package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.SetmealDish;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {
    /**
     * 根据菜品id查询对应的套餐id
     * @param dishIds
     * @return
     */
    List<Long> getSetmealIdsByDishIds(List<Long> dishIds);

    /**
     * 在套餐菜品表中插入套餐的菜品信息
     * @param setmealDish
     */

    @Insert("insert into setmeal_dish (id, setmeal_id, dish_id, name, price, copies) " +
            "values (#{id},#{setmealId},#{dishId},#{name},#{price},#{copies})")
    void save(SetmealDish setmealDish);

    /**
     * 根据id查询套餐信息
     * @param id
     * @return
     */
    @Select("select * from setmeal_dish where setmeal_id=#{id}")
    List<SetmealDish> getDishsBySetmealId( Integer id);

    /**
     * 删除套餐菜品中的信息
     * @param id
     */
    @Delete("delete from setmeal_dish where setmeal_id = #{id}")
    void deleteBySetmealId(Integer id);
}
